package com.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author CHL
 * @ClassName: RegistryFetchInfosHandler
 * @Description: 处理sender元数据拉取
 * @date 2022/12/30 16:22
 * @Version 1.0
 */

public class RegistryFetchInfosHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
        if ("fetch registry infos".equalsIgnoreCase(s)) {
            RegistryInfo registryInfo = new RegistryInfo();
            registryInfo.setHost(RegistryCache.consumerHost);
            registryInfo.setPort(RegistryCache.consumerPort);
            channelHandlerContext.channel().writeAndFlush(registryInfo);

            System.out.println("sender到注册中心获取注册信息:" + registryInfo);
        }
    }

}
